package com.taffywen.study.spring_cloud_learn.demo;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.time.LocalDateTime;

public class Demo01 {


    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();

        // 减去1.5分钟
//        LocalDateTime oneAndAHalfMinutesAgo = now.minus(1.5l, ChronoUnit.MINUTES);
        // 减去1.5分钟
        LocalDateTime oneAndAHalfMinutesAgo = now.minus(1, ChronoUnit.MINUTES)
                .minus(30, ChronoUnit.SECONDS);


        // 将 LocalDateTime 转换为 Instant
        ZonedDateTime zonedDateTime = oneAndAHalfMinutesAgo.atZone(ZoneId.systemDefault());
        long milliseconds = zonedDateTime.toInstant().toEpochMilli();

        long endTim = new Date().getTime();
        System.out.println(startTime);
        System.out.println(startTime - milliseconds);
        long min = 2;
        long chae = 1000*60*min;
        System.out.println(chae);
        if (startTime - milliseconds <= chae)
            System.out.println("超时");
    }
}
